package logic

import (
	"context"
	"medicals/models/mysql"

	"medicals/medicalrpc/internal/svc"
	"medicals/medicalrpc/medicalrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type MedicalAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewMedicalAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MedicalAddLogic {
	return &MedicalAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *MedicalAddLogic) MedicalAdd(in *medicalrpc.MedicalAddRequest) (*medicalrpc.MedicalAddResponse, error) {
	// todo: add your logic here and delete this line

	medical := mysql.Medical{

		Image: in.Image,
		Name:  in.Name,
		Phone: in.Phone,
		Class: in.Class,
		Price: float64(in.Price),
	}
	mysql.DB.Debug().Create(&medical)
	return &medicalrpc.MedicalAddResponse{
		Id: int64(medical.ID),
	}, nil
}
